<?php
/**
 * Created by PhpStorm
 * @author: yiyu
 * @time: 2020/3/3 22:27
 * @desc:
 * @fileName: MarqueeController.php
 */

namespace app\api\controller;

use app\api\service\MarqueeService;
use app\core\exception\{BusinessException, ErrorCode};

class MarqueeController extends ApiBaseController
{
    protected $beforeActionList = [
        'checkLogin',
    ];

    public function getHomeMarquee()
    {
        $data = MarqueeService::instance()->getHomeMarquee($this->user_id, 10);

        return $this->successReturn($data);
    }

    public function getGoodsDetailMarquee()
    {
        $goods_id = input('goods_id/d', 0);

        if (empty($goods_id)) {
            throw new BusinessException(ErrorCode::COMMON_LACK_PARAMS, '商品id不能为空');
        }
        $data = MarqueeService::instance()->getGoodsDetailMarquee($this->user_id, $goods_id, 10);

        return $this->successReturn($data);
    }

    public function getWishDetailMarquee()
    {
        $goods_id = input('goods_id/d', 0);

        if (empty($goods_id)) {
            throw new BusinessException(ErrorCode::COMMON_LACK_PARAMS, '商品id不能为空');
        }

        $data = MarqueeService::instance()->getWishDetailMarquee($this->user_id, $goods_id, 5);

        return $this->successReturn($data);
    }


}